/*     */ package com.wzh.action.control.book;
/*     */ 
/*     */ import com.opensymphony.xwork2.ActionContext;
/*     */ import com.opensymphony.xwork2.ActionSupport;
/*     */ import com.wzh.bean.PageView;
/*     */ import com.wzh.bean.QueryResult;
/*     */ import com.wzh.bean.book.BookChapter;
/*     */ import com.wzh.constant.CommonConstant;
/*     */ import com.wzh.service.bookinfo.chapter.BookChapterService;
/*     */ import java.io.Serializable;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import javax.annotation.Resource;
/*     */ import org.springframework.stereotype.Controller;
/*     */ 
/*     */ @Controller
/*     */ public class ChapterManageAction extends ActionSupport
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*     */ 
/*     */   @Resource
/*     */   private BookChapterService chapterService;
/*     */   private Integer bookid;
/*     */   private String bookname;
/*  28 */   private int page = 1;
/*     */   private String title;
/*     */   private int chapterid;
/*     */ 
/*     */   public int getChapterid()
/*     */   {
/*  35 */     return this.chapterid;
/*     */   }
/*     */ 
/*     */   public void setChapterid(int chapterid) {
/*  39 */     this.chapterid = chapterid;
/*     */   }
/*     */ 
/*     */   public String getTitle() {
/*  43 */     return this.title;
/*     */   }
/*     */ 
/*     */   public void setTitle(String title) {
/*  47 */     this.title = title;
/*     */   }
/*     */ 
/*     */   public int getPage() {
/*  51 */     return this.page;
/*     */   }
/*     */ 
/*     */   public void setPage(int page) {
/*  55 */     this.page = page;
/*     */   }
/*     */ 
/*     */   public String getBookname() {
/*  59 */     return this.bookname;
/*     */   }
/*     */ 
/*     */   public void setBookname(String bookname) {
/*  63 */     this.bookname = bookname;
/*     */   }
/*     */ 
/*     */   public Integer getBookid() {
/*  67 */     return this.bookid;
/*     */   }
/*     */ 
/*     */   public void setBookid(Integer bookid) {
/*  71 */     this.bookid = bookid;
/*     */   }
/*     */ 
/*     */   public String index()
/*     */   {
/*  76 */     PageView pageView = new PageView(CommonConstant.MAXRESULT, this.page);
/*     */ 
/*  78 */     int firstIndex = (this.page - 1) * CommonConstant.MAXRESULT;
/*     */ 
/*  81 */     String whereStr = " o.bookid=?1 ";
/*  82 */     List params = new ArrayList();
/*  83 */     params.add(this.bookid);
/*     */ 
/*  85 */     if ((this.title != null) && (!"".equals(this.title.trim()))) {
/*  86 */       whereStr = whereStr + " and o.title=?2";
/*  87 */       params.add(this.title.trim());
/*     */     }
/*     */ 
/*  91 */     QueryResult qr = 
/*  92 */       this.chapterService.getScrollData(firstIndex, 
/*  93 */       CommonConstant.MAXRESULT, whereStr, params.toArray());
/*  94 */     pageView.setRecords(qr.getResultlist());
/*  95 */     pageView.setTotalrecords((int)qr.getTotalrecord());


/*  96 */     ActionContext.getContext().put("pageView", pageView);
/*  97 */     return "chapterindex";
/*     */   }
/*     */ 
/*     */   public String delete()
/*     */   {
/* 102 */     this.chapterService.delete(new Serializable[] { Integer.valueOf(this.chapterid) });
/* 103 */     ActionContext.getContext().put("message", "删除成功");
/* 104 */     ActionContext.getContext().put("urladdress", 
/* 105 */       "/control/book/chapter/chapterlist?bookid=" + this.bookid + "&bookname=" + this.bookname);
/* 106 */     return "message";
/*     */   }
/*     */ 
/*     */   public String edit() {
/* 110 */     BookChapter chapter = (BookChapter)this.chapterService.find(Integer.valueOf(this.chapterid));
/* 111 */     ActionContext.getContext().put("chapter", chapter);
/* 112 */     return "edit";
/*     */   }
/*     */ 
/*     */   public String update() {
/* 116 */     BookChapter chapter = (BookChapter)this.chapterService.find(Integer.valueOf(this.chapterid));
/* 117 */     chapter.setTitle(this.title);
/* 118 */     this.chapterService.update(chapter);
/* 119 */     ActionContext.getContext().put("message", "修改成功");
/* 120 */     ActionContext.getContext().put("urladdress", 
/* 121 */       "/control/book/chapter/chapterlist?bookid=" + this.bookid + "&bookname=" + this.bookname);
/* 122 */     return "message";
/*     */   }
/*     */ }

/* Location:           C:\work\apache-tomcat-7.0.55\webapps\ROOT\WEB-INF\classes\
 * Qualified Name:     com.wzh.action.control.book.ChapterManageAction
 * JD-Core Version:    0.6.1
 */